#pragma once

#include <string>
#include <set>
#include <functional>
#include "Singleton.h"
#include "MsgRouter.h"
#include "agencyevent.h"

class AgencyEventService
{
public:
    bool Init();

public:
    AgencyEventService() = default;
    virtual ~AgencyEventService() = default;

public:
    static AgencyEventService* Instance()
	{
		return CSingleton<AgencyEventService>::Instance();
	}

public:
    bool HandleGetAgencyEvent(const std::uint32_t& agencyid, std::string&& trans, std::uint64_t sence);
    void OnAgencyEventGet(MsgData&& data);
    void OnSenceAgencyEventGet(std::uint64_t sence, std::string&& trans, std::int32_t err_code, stAgencyEvent* agency);
    inline void ListenOnAgencyEventGet(std::uint64_t sence, std::function<void(std::int32_t err_code, stAgencyEvent*  agency, std::string&& trans)> listen)
    {
        m_agencyevent_get_listen[sence] = listen;
    }

    bool HandleGetAgencyId(const std::string& agency_name, std::string&& trans, std::uint64_t sence);
    void OnGetAgencyId(MsgData&& data);
private:
    std::map<std::uint64_t, std::function<void(std::int32_t err_code, stAgencyEvent* agencyevent, std::string&& trans)>> m_agencyevent_get_listen;

};










